﻿
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
namespace WCYCReader.ImageTool
{
    public static class Decoders
    {
        private static List<Type> _decoderTypes = new List<Type>();

        public static void AddDecoder<TDecoder>() where TDecoder: IImageDecoder
        {
            if (!_decoderTypes.Contains(typeof(TDecoder)))
            {
                _decoderTypes.Add(typeof(TDecoder));
            }
        }

        public static ReadOnlyCollection<IImageDecoder> GetAvailableDecoders()
        {
            List<IImageDecoder> list = new List<IImageDecoder>();
            foreach (Type type in _decoderTypes)
            {
                list.Add(Activator.CreateInstance(type) as IImageDecoder);
            }
            return new ReadOnlyCollection<IImageDecoder>(list);
        }
    }
}

